#include <Arduino_APDS9960.h>

void setup() {
	Serial.begin(9600);
	while (!Serial);
	APDS.setLEDBoost(3);
	if (!APDS.begin()) {
		Serial.println("Error initializing APDS-9960 sensor.");
	}

	// For setGestureSensitivity(...), a value between 1 and 100 is required.
	// Higher values make the gesture recognition more sensitive but less accurate
	// (a wrong gesture may be detected by the sensor). Lower values makes the gesture recognition
	// more accurate but less sensitive (some gestures may be missed by the sensor).
	// Default value is 80.

	APDS.setGestureSensitivity(100);

	Serial.println("Detecting gestures ...");
}

void loop() {
	if (APDS.gestureAvailable()) {
		// A gesture was detected, read and print to Serial Monitor.
		int gesture = APDS.readGesture();

		switch (gesture) {
			case GESTURE_UP:
				Serial.println("Detected UP gesture");
				break;

			case GESTURE_DOWN:
				Serial.println("Detected DOWN gesture");
				break;

			case GESTURE_LEFT:
				Serial.println("Detected LEFT gesture");
				break;

			case GESTURE_RIGHT:
				Serial.println("Detected RIGHT gesture");
				break;

			default:
				// Ignore.
				break;
		}
	}
}
